/**
 * Created by baidm in 2022/5/5 on 21:55
 */
import MapDemoConst from "@/const/MapDemoConst"
import {ref} from "vue"
import {openWindow} from "@/hooks/useCommon"
import {useRouter} from "vue-router";

export default function () {
  const router = useRouter()

  let menuStatusRef = ref(true);
  let mapDemoListRef = ref([
    {name: "添加 marker", id: MapDemoConst.ADD_MARKER},
    {name: "添加 image marker", id: MapDemoConst.ADD_IMAGE_MARKER},
    {name: "添加 merge image marker", id: MapDemoConst.ADD_MERGE_IMAGE_MARKER},
    {name: "添加 circle marker", id: MapDemoConst.ADD_CIRCLE_MARKER},
    {name: "添加 vector marker", id: MapDemoConst.ADD_VECTOR_MARKER},
    {name: "添加 marker rightmenu", id: MapDemoConst.ADD_MARKER_RIGHTMENU},
    {name: "添加 marker infowindow", id: MapDemoConst.ADD_MARKER_INFOWINDOW},
    {name: "添加 line", id: MapDemoConst.ADD_LINE},
    {name: "添加 gradient line", id: MapDemoConst.ADD_GRADIENT_LINE},
    {name: "添加 line with direction marker", id: MapDemoConst.ADD_LINE_WITH_DIRECTION_MARKER},
    {name: "添加 smoothness line", id: MapDemoConst.ADD_SMOOTHNESS_LINE},
    {name: "添加 polygon", id: MapDemoConst.ADD_POLYGON},
    {name: "添加 marker wave", id: MapDemoConst.ADD_MARKER_WAVE},
    {name: "添加 UI marker", id: MapDemoConst.ADD_UI_MARKER},
    {name: "添加 UI echarts pie", id: MapDemoConst.ADD_UI_ECHARTS_PIE},
    {name: "添加 UI echarts graph", id: MapDemoConst.ADD_UI_ECHARTS_GRAPH},
    {name: "添加 layer mask", id: MapDemoConst.ADD_LAYER_MASK},
    {name: "筛选 polygon", id: MapDemoConst.FILTER_POLYGON},
    {name: "设置 图层层级", id: MapDemoConst.SET_LAYER_INDEX},
    {name: "添加 粒子图层", id: MapDemoConst.ADD_PARTICLE_LAYER},
    {name: "添加 image layer", id: MapDemoConst.ADD_IMAGE_LAYER},
    {name: "添加 鱼鹰眼", id: MapDemoConst.ADD_MAGNIFIER},
    {name: "添加 distance tool", id: MapDemoConst.ADD_DISTANCE_TOOL},
    {name: "添加 area tool", id: MapDemoConst.ADD_AREA_TOOL},
    {name: "添加 draw tool", id: MapDemoConst.ADD_DRAW_TOOL},
    {name: "添加 draggabled", id: MapDemoConst.ADD_DRAGGABLED},
    {name: "添加 editeabled", id: MapDemoConst.ADD_EDITABLED},
    {name: "添加 animated marker", id: MapDemoConst.ADD_ANIMATED_MARKER},
    {name: "添加 animated line", id: MapDemoConst.ADD_ANIMATED_LINE},
    {name: "添加 animated polygon", id: MapDemoConst.ADD_ANIMATED_POLYGON},
    {name: "添加 animated custom", id: MapDemoConst.ADD_ANIMATED_CUSTOM},
    {name: "添加 全屏", id: MapDemoConst.ADD_FULLSCREEN},
    {name: "添加 heat layer", id: MapDemoConst.ADD_HEAT_LAYER},
    {name: "添加 cluster marker", id: MapDemoConst.ADD_CLUSTER_MARKER},
    {name: "添加 animate marker", id: MapDemoConst.ADD_ANIMATE_MARKER},
    {name: "添加 odline migration", id: MapDemoConst.ADD_ODLINE_MIGRATION},
    {name: "添加 odline curves", id: MapDemoConst.ADD_ODLINE_CURVES},
    {name: "添加 echarts bus", id: MapDemoConst.ADD_ECHARTS_BUS},
    {name: "添加 echarts fly", id: MapDemoConst.ADD_ECHARTS_FLY},
    {name: "添加 windy layer", id: MapDemoConst.ADD_WINDY_LAYER},
    {name: "添加 isects", id: MapDemoConst.ADD_ISECTS},
    {name: "添加 toolbar", id: MapDemoConst.ADD_TOOLBAR},
    {name: "添加 route play", id: MapDemoConst.ADD_ROUTE_PLAY},
    {name: "添加 route play multi", id: MapDemoConst.ADD_ROUTE_PLAY_MULTI},
  ]);

  //切换展示demo
  const toggleMapDemo = (menu) => {
    let findRes = mapDemoListRef.value.find(item => item.id === menu.id)
    switch (menu.id) {
      case MapDemoConst.ADD_MARKER:
        openWindow(router, "addMarker", findRes.name)
        break;
      case MapDemoConst.ADD_IMAGE_MARKER:
        openWindow(router, "addImageMarker", findRes.name)
        break;
      case MapDemoConst.ADD_MERGE_IMAGE_MARKER:
        openWindow(router, "AddMergeImageMarker", findRes.name)
        break;
      case MapDemoConst.ADD_CIRCLE_MARKER:
        openWindow(router, "addCircleMarker", findRes.name)
        break;
      case MapDemoConst.ADD_VECTOR_MARKER:
        openWindow(router, "addVectorMarker", findRes.name)
        break;
      case MapDemoConst.ADD_MARKER_RIGHTMENU:
        openWindow(router, "addMarkerRightmenu", findRes.name)
        break;
      case MapDemoConst.ADD_MARKER_INFOWINDOW:
        openWindow(router, "addMarkerInfowindow", findRes.name)
        break;
      case MapDemoConst.ADD_LINE:
        openWindow(router, "addLine", findRes.name)
        break;
      case MapDemoConst.ADD_GRADIENT_LINE:
        openWindow(router, "addGradientLine", findRes.name)
        break;
      case MapDemoConst.ADD_LINE_WITH_DIRECTION_MARKER:
        openWindow(router, "addLineWithDirectionMarker", findRes.name)
        break;
      case MapDemoConst.ADD_SMOOTHNESS_LINE:
        openWindow(router, "addSmoothnessLine", findRes.name)
        break;
      case MapDemoConst.ADD_POLYGON:
        openWindow(router, "addPolygon", findRes.name)
        break;
      case MapDemoConst.ADD_MARKER_WAVE:
        openWindow(router, "addMarkerWave", findRes.name)
        break;
      case MapDemoConst.ADD_UI_MARKER:
        openWindow(router, "addUIMarker", findRes.name)
        break;
      case MapDemoConst.ADD_UI_ECHARTS_PIE:
        openWindow(router, "addUIEchartsPie", findRes.name)
        break;
      case MapDemoConst.ADD_UI_ECHARTS_GRAPH:
        openWindow(router, "addUIEchartsGraph", findRes.name)
        break;
      case MapDemoConst.ADD_LAYER_MASK:
        openWindow(router, "addLayerMask", findRes.name)
        break;
      case MapDemoConst.FILTER_POLYGON:
        openWindow(router, "filterPolygon", findRes.name)
        break;
      case MapDemoConst.SET_LAYER_INDEX:
        openWindow(router, "setLayerIndex", findRes.name)
        break;
      case MapDemoConst.ADD_PARTICLE_LAYER:
        openWindow(router, "addParticleLayer", findRes.name)
        break;
      case MapDemoConst.ADD_IMAGE_LAYER:
        openWindow(router, "addImageLayer", findRes.name)
        break;
      case MapDemoConst.ADD_MAGNIFIER:
        openWindow(router, "addMagnifier", findRes.name)
        break;
      case MapDemoConst.ADD_DISTANCE_TOOL:
        openWindow(router, "addDistanceTool", findRes.name)
        break;
      case MapDemoConst.ADD_AREA_TOOL:
        openWindow(router, "addAreaTool", findRes.name)
        break;
      case MapDemoConst.ADD_DRAW_TOOL:
        openWindow(router, "addDrawTool", findRes.name)
        break;
      case MapDemoConst.ADD_DRAGGABLED:
        openWindow(router, "addDraggabled", findRes.name)
        break;
      case MapDemoConst.ADD_EDITABLED:
        openWindow(router, "addEditabled", findRes.name)
        break;
      case MapDemoConst.ADD_ANIMATED_MARKER:
        openWindow(router, "addAnimatedMarker", findRes.name)
        break;
      case MapDemoConst.ADD_ANIMATED_LINE:
        openWindow(router, "addAnimatedLine", findRes.name)
        break;
      case MapDemoConst.ADD_ANIMATED_POLYGON:
        openWindow(router, "addAnimatedPolygon", findRes.name)
        break;
      case MapDemoConst.ADD_ANIMATED_CUSTOM:
        openWindow(router, "addAnimatedCustom", findRes.name)
        break;
      case MapDemoConst.ADD_FULLSCREEN:
        openWindow(router, "addFullscreen", findRes.name)
        break;
      case MapDemoConst.ADD_HEAT_LAYER:
        openWindow(router, "addHeatLayer", findRes.name)
        break;
      case MapDemoConst.ADD_CLUSTER_MARKER:
        openWindow(router, "addClusterMarker", findRes.name)
        break;
      case MapDemoConst.ADD_ANIMATE_MARKER:
        openWindow(router, "addAnimateMarker", findRes.name)
        break;
      case MapDemoConst.ADD_ODLINE_MIGRATION:
        openWindow(router, "addOdlineMigration", findRes.name)
        break;
      case MapDemoConst.ADD_ODLINE_CURVES:
        openWindow(router, "addOdlineCurves", findRes.name)
        break;
      case MapDemoConst.ADD_ECHARTS_BUS:
        openWindow(router, "addEchartsBus", findRes.name)
        break;
      case MapDemoConst.ADD_ECHARTS_FLY:
        openWindow(router, "addEchartsFly", findRes.name)
        break;
      case MapDemoConst.ADD_WINDY_LAYER:
        openWindow(router, "addWindyLayer", findRes.name)
        break;
      case MapDemoConst.ADD_ISECTS:
        openWindow(router, "addIsects", findRes.name)
        break;
      case MapDemoConst.ADD_TOOLBAR:
        openWindow(router, "addToolbar", findRes.name)
        break;
      case MapDemoConst.ADD_ROUTE_PLAY:
        openWindow(router, "addRoutePlay", findRes.name)
        break;
      case MapDemoConst.ADD_ROUTE_PLAY_MULTI:
        openWindow(router, "addRoutePlayMulti", findRes.name)
        break;
    }
  }

  return {
    menuStatusRef, mapDemoListRef, toggleMapDemo
  }
}
